package SuperMarket;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "STOREUSER", catalog = "", schema = "PLH24")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Storeuser.findAll", query = "SELECT s FROM Storeuser s"),
    @NamedQuery(name = "Storeuser.findByUserId", query = "SELECT s FROM Storeuser s WHERE s.userId = :userId"),
    @NamedQuery(name = "Storeuser.findByFirstName", query = "SELECT s FROM Storeuser s WHERE s.firstName = :firstName"),
    @NamedQuery(name = "Storeuser.findByLastName", query = "SELECT s FROM Storeuser s WHERE s.lastName = :lastName"),
    @NamedQuery(name = "Storeuser.findByAddress", query = "SELECT s FROM Storeuser s WHERE s.address = :address"),
    @NamedQuery(name = "Storeuser.findByPointsCardNumber", query = "SELECT s FROM Storeuser s WHERE s.pointsCardNumber = :pointsCardNumber"),
    @NamedQuery(name = "Storeuser.findByAvailablePoints", query = "SELECT s FROM Storeuser s WHERE s.availablePoints = :availablePoints"),
    @NamedQuery(name = "Storeuser.findByNoOfChecks", query = "SELECT s FROM Storeuser s WHERE s.noOfChecks = :noOfChecks"),
    @NamedQuery(name = "Storeuser.findByAdmin", query = "SELECT s FROM Storeuser s WHERE s.admin = :admin")})
public class Storeuser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "USER_ID")
    private Integer userId;
    @Basic(optional = false)
    @Column(name = "FIRST_NAME")
    private String firstName;
    @Basic(optional = false)
    @Column(name = "LAST_NAME")
    private String lastName;
    @Column(name = "ADDRESS")
    private String address;
    @Basic(optional = false)
    @Column(name = "POINTS_CARD_NUMBER")
    private String pointsCardNumber;
    @Basic(optional = false)
    @Column(name = "AVAILABLE_POINTS")
    private int availablePoints;
    @Column(name = "NO_OF_CHECKS")
    private Integer noOfChecks;
    @Basic(optional = false)
    @Column(name = "ADMIN")
    private Serializable admin;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "storeuser")
    private List<Purchase> purchaseList;

    public Storeuser() {
    }

    public Storeuser(Integer userId) {
        this.userId = userId;
    }

    public Storeuser(Integer userId, String firstName, String lastName, String pointsCardNumber, int availablePoints, Serializable admin) {
        this.userId = userId;
        this.firstName = firstName;
        this.lastName = lastName;
        this.pointsCardNumber = pointsCardNumber;
        this.availablePoints = availablePoints;
        this.admin = admin;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPointsCardNumber() {
        return pointsCardNumber;
    }

    public void setPointsCardNumber(String pointsCardNumber) {
        this.pointsCardNumber = pointsCardNumber;
    }

    public int getAvailablePoints() {
        return availablePoints;
    }

    public void setAvailablePoints(int availablePoints) {
        this.availablePoints = availablePoints;
    }

    public Integer getNoOfChecks() {
        return noOfChecks;
    }

    public void setNoOfChecks(Integer noOfChecks) {
        this.noOfChecks = noOfChecks;
    }

    public Serializable getAdmin() {
        return admin;
    }

    public void setAdmin(Serializable admin) {
        this.admin = admin;
    }

    @XmlTransient
    public List<Purchase> getPurchaseList() {
        return purchaseList;
    }

    public void setPurchaseList(List<Purchase> purchaseList) {
        this.purchaseList = purchaseList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Storeuser)) {
            return false;
        }
        Storeuser other = (Storeuser) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "SuperMarket.Storeuser[ userId=" + userId + " ]";
    }
    
}
